﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GradeTreeList.aspx.cs" Inherits="School_GradeTreeList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>年级列表</title>
    
    <link href="../Common/css/main.css" rel="stylesheet" type="text/css" />    
    <script type="text/javascript" src="../Common/Js/jquery.js"></script>
    <script type="text/javascript" src="../Common/Js/common.js"></script>
    <script type="text/javascript" src="../Common/Js/msg.js"></script>
    <script type="text/javascript" src="../Common/Js/xTree/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="../Common/Js/xTree/dhtmlxtree.js"></script>
    <link href="../Common/css/dhtmlxtree.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

window.onload = InitClassList;

var activate = 1;
var tree;

function InitClassList()
{
    tree=new dhtmlXTreeObject('treeBox',"100%","100%",0);
    tree.setImagePath("../Common/images/xTreeImgs/");
    
    var FirstID=0;
    
    PageMethods.GetSchoolType(function(succ)
    {
        if (succ > 0)
        {
             var arrGrade = GetGradeInfo(succ);
             for (var i=0; i<arrGrade.length; i++)
             {
                if (FirstID == 0)
                    FirstID = arrGrade[i].gradeIndex;
                    
                tree.insertNewChild(0,arrGrade[i].gradeIndex,arrGrade[i].gradeName,0,"group.gif","group.gif","group.gif","");
             }
             
        }
        else
            self.parent.showMassgeBox("提示","学校性质为空，无法获取对应年级信息",1,null);   
        
        if (FirstID != 0)
        {
            self.parent.currClass = FirstID;
            tree.selectItem(self.parent.currClass, true);
            self.parent.frames["right"].location  = "ClassGrid.aspx?id="+FirstID;
        }
    })
    var id = -1;

    tree.setItemStyle(id,"../Common/css/");
    tree.setOnClickHandler(treeOnClick);
}

function treeOnClick(id)
{
    if(activate == 0)
    {
        tree.selectItem(self.parent.currClass, false);
        self.parent.frames["right"].showMassgeBox('提示','您还有未保存的项,请保存后再切换班级');
        
    }

    if(id > 0)
    {
        self.parent.currClass = id;
        self.parent.frames["right"].location  = "ClassGrid.aspx?id="+id;
    }
    else
    {
        if(self.parent.currClass != null && self.parent.currClass > 0)
          tree.selectItem(self.parent.currClass, false);
    }
}

</script>

</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
	<div class="oneTreeBody">
            <div class="treeMain">
                 <div style="height:95%; width:170px; overflow:auto;" id="treeBox"></div>
      		</div>
    </div>  
         </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
